TQuery
Type queried
IdeaBlade DevForce 2010 Help Reference
Filter<TQuery>(TQuery,EntityQueryFilterCollection) Method
See Also  Example Send Feedback
IdeaBlade.EntityModel Assembly > IdeaBlade.EntityModel Namespace > EntityQueryExtensions Class > Filter Method : Filter<TQuery>(TQuery,EntityQueryFilterCollection) Method



query
Query to be appended to
filters
Collection of filters
Append the specified filter collection to the query.

Syntax

Visual Basic (Declaration) 
<ExtensionAttribute()>
Public Overloads Shared Function Filter(Of TQuery As ITypedEntityQuery)( _
   ByVal query As TQuery, _
   ByVal filters As EntityQueryFilterCollection _
) As TQuery
Visual Basic (Usage)Copy Code
Dim query As TQuery
Dim filters As EntityQueryFilterCollection
Dim value As TQuery
 
value = EntityQueryExtensions.Filter(Of TQuery)(query, filters)
C# 
[ExtensionAttribute()]
public static TQuery Filter<TQuery>( 
   TQuery query,
   EntityQueryFilterCollection filters
)
where TQuery: ITypedEntityQuery
C++/CLI 
[ExtensionAttribute()]
public:
static TQuery^ Filtergeneric<typename TQuery>
( 
   TQuery^ query,
   EntityQueryFilterCollection^ filters
) 
where TQuery: ITypedEntityQuery

Parameters

query
Query to be appended to
filters
Collection of filters

Type Parameters

TQuery
Type queried

Return Value

A new query

Example

C#Copy Code
public void FilteringSample() {
  // Query for all customers.  A filter will be applied prior to execution.
  var mgr = new DomainModelEntityManager();
  mgr.Querying += new EventHandler<EntityQueryingEventArgs>(mgr_Querying);
  var list = mgr.Customers.ToList();
}

// Client-side filtering in the EM.Querying event handler
private void mgr_Querying(object sender, EntityQueryingEventArgs e) {
  EntityQueryFilterCollection clientFilters = new EntityQueryFilterCollection();
  clientFilters.AddFilter<Customer>(q => q.Where(c => c.Country == "UK"));
  e.Query = e.Query.Filter(clientFilters);
}

Remarks

You can use an EntityQueryFilterCollection to filter different entity types in the query. The collection can also contain filters for types not currently in the query, and those filters will be ignored when the query is executed.

The Filter is most useful in appending to an existing query on the server prior to execution, where you cannot easily modify the query expression provided. The query may also be filtered on the client using the Querying event.

Note that Filter returns a new query with the filter(s) added; the original query is not modified.

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© 2013 All Rights Reserved.